package cn.gdcp.recyclerview;

import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

/**
 * Created by yls on 2018/10/22.
 */

public class StuViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener{
    IOnitemClick listener;
    ImageView headView;
    TextView nameView;
    TextView ageView;
    Button ivDel;
    View view;

    public StuViewHolder(View itemView) {
        super(itemView);
        this.view = itemView;

        ivDel = view.findViewById(R.id.iv_del);
        headView = view.findViewById(R.id.iv_head);
        nameView = view.findViewById(R.id.iv_name);
        ageView = view.findViewById(R.id.iv_age);
        ivDel.setOnClickListener(this);
    }
    public StuViewHolder(View itemView,IOnitemClick listener) {
        super(itemView);
        this.view = itemView;
        this.listener = listener;

        ivDel = view.findViewById(R.id.iv_del);
        headView = view.findViewById(R.id.iv_head);
        nameView = view.findViewById(R.id.iv_name);
        ageView = view.findViewById(R.id.iv_age);

        ivDel.setOnClickListener(this);
        headView.setOnClickListener(this);
        nameView.setOnClickListener(this);
        ageView.setOnClickListener(this);
        itemView.setOnClickListener(this);
        view.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        if(listener!=null) {
            listener.IOnitemClick(getAdapterPosition(), v);
        }
    }
}
